import 'package:flutter/material.dart';
import 'package:flutter_widgets/flutter_widgets.dart';

class EmptySample extends StatefulWidget {
  static const routeName = 'empty_sample';

  @override
  State<EmptySample> createState() => _EmptySampleState();
}

class _EmptySampleState extends State<EmptySample> {
  var _isEmpty = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonAppBar(
        titleData: EmptySample.routeName,
        actions: <Widget>[
          CommonFlatButton(
            text: '点击切换空态页状态',
            onPressed: () {
              setState(() {
                _isEmpty = !_isEmpty;
              });
            },
          ),
        ],
      ),
      body: EmptyView(
        isEmpty: _isEmpty,
        emptyText: '啥数据也没有～',
        emptyStyle: const EmptyStyle(
          alignment: Alignment.center,
        ),
        child: const Center(
          child: Text('content'),
        ),
      ),
    );
  }
}
